{include file="public/admin_head.html"}
<script type="text/javascript" src="{$host}/files/js/uploadify/jquery.uploadify.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/files/js/ue_editor/editor_config.js"></script>
<script type="text/javascript" charset="utf-8" src="/files/js/ue_editor/_examples/editor_api.js"></script>


<body>
<form class="form-horizontal" method ="post" action ="./index.php?act=news&st=newsEdit"  onsubmit="return checkForm();">
	<legend>
		<B>修改新闻</B>
	</legend>
	<div class="control-group">
	  <label for="input01" class="control-label">标题：<font color="#FF0000">*</font></label>
	  <div class="controls">
	    <input type="text" id="title" class="input-xlarge" name="title" value="{$info.title}">
	  </div>
	</div>
	
	<div class="control-group">
	  <label for="author" class="control-label">作者：</label>
	  <div class="controls">
	    <input type="text" id="author" class="input-xlarge" name="author" value="{$info.author}">
	  </div>
	</div>	

	<div class="control-group">
	  <label for="input01" class="control-label">所属栏目：<font color="#FF0000">*</font></label>
	  <div class="controls">
	    <select name="category_id">
	    	{foreach item=item key=key from=$topic}
	    		<option value="{$item.category_id}" {if $item.category_id == $info.category_id}selected="selected"{/if})>{$item.category_name}</option>
	    	{/foreach}
	    </select>
	  </div>
	</div>
	
	<div class="control-group">
	  <label for="input01" class="control-label">摘要：</label>
	  <div class="controls">
	    <textarea rows="3" cols="50" name="digest" style="width: 270px; height: 80x;">{$info.digest}</textarea>
	  </div>
	</div>
	<div class="control-group">
	  <label for="article_index" class="control-label">排序：</label>
	  <div class="controls">
	    <input type="text" id="article_index" name="article_index" value="{$info.article_index}" style="width:50px" />&nbsp;&nbsp;数字越大越靠前
	  </div>
	</div>
	<div class="control-group">
	    <label for="input01" class="control-label">封面图<font color="#FF0000">*</font>：</label>
	    <div class="controls">
		<input type="file" id="uploadify" class="input-xlarge" name="uploadify" value="" style="display:none">
		<input type="hidden" id="ad_img_path" name="ad_img_path" value="{$info.picurl}">
		<span class="label" id="upload_comment" style="display:none">支持JPG、PNG格式<br/>较好的效果为大图360*200，小图200*200</span>
	    </div>
	    <div class="controls" id="image_play">
	    {if $info.picurl != ''}
	    	<div style="width:460px;height:200px;float:left;margin-left:10px;">
				<div style="width:360px;height:200px;float:left;">
					<img style="width:100%;height:100%" src="{$info.picurl}">
				</div>
				<span id="delbutton"  style="cursor: pointer; color: red; margin-left: 2px; width: 50px; float: left;" alt="删除" title="删除" onclick="delImage();">[ 删除 ]</span>
			</div>
	    {/if}
	    </div>
	</div>
	<div class="control-group" style="display:none;"><!-- 暂时隐去这个选项，后期扩展 -->
	  <label for="show_cover_pic" class="control-label">是否设为封面：</label>
	  <div class="controls">
		<label class="checkbox">
			<input type="checkbox" name="show_cover_pic" value="1" id="show_cover_pic"{if $info.show_cover_pic==1}checked="checked"{/if} />
		</label>
	  </div>
	</div>
	<div class="control-group">
	  <label for="content_source_url" class="control-label">图文消息地址：</label>
	  <div class="controls">
	    <input type="text" id="content_source_url" class="input-xlarge" name="content_source_url" value="{$info.content_source_url}" /><br/>
	    <font color="red">备注：在微信公众平台的【素材管理】上传的图文消息的文章地址。填写此项后，可以不需要填写下面的“新闻内容”字段。</font>
	  </div>
	</div>
	<div class="control-group" >
	  <label for="input01" class="control-label">新闻内容：<font color="#FF0000">*</font></label>
	  <div class="controls" style="width:600px">
	    <script id="content" type="text/plain" name="content" >{$info.content}</script>
	  </div>
	</div>
	<div class="form-actions">
		<a href="javascript:history.back();" class="btn width-100">返回</a>
		<input type="hidden" name="id" value="{$info.id}" />
		<button class="btn btn-primary width-100 left-60" type="submit"> 确 认 </button>
	</div>
    </form>
<script type="text/javascript">
//实例化编辑器
var ue = UE.getEditor('content',{
	initialFrameWidth:600,
});
function checkForm() {
	if($("#title").val() == '') {
		alert("请输入标题！");
		$("#title").focus();
		return false;
	}
	if($("#ad_img_path").val() == '') {
		alert("请上传封面图片！");
		return false;
	}
	return true;
}
$(function() {
    $('#uploadify').uploadify({
        'buttonText'      	: '上传封面图片',
        'swf'      			: '{$host}/files/js/uploadify/uploadify.swf',
        'uploader' 			: '{$host}/index.php?act=news&st=imageUplody',
        'cancelImg'			: '{$host}/files/js/uploadify/uploadify-cancel.png',
        'auto' 				: true,
        'onUploadSuccess' 	: function(file, data, response) {
            var ad_img = $('#ad_img_path').val();
            var data = eval('('+data+')');

            if(data['state'] == 'SUCCESS'){
                $("#image_play").html('<div style="width:460px;height:200px;float:left;margin-left:10px;"><div style="width:360px;height:200px;float:left;"><img style="width:100%;height:100%" src="'+data['url']+'"></div>&nbsp;<span id="delbutton"  style="cursor: pointer; color: red; margin-left: 2px; width: 50px; float: left;" alt="删除" title="删除" onclick="delImage();">[ 删除 ]</span></div>');
                $("#uploadify").hide();
                $("#upload_comment").hide();
              //  delImage();
                $("#ad_img_path").val(data['url']);                  
            }else{
                alert(data['state']);
                return false;
            }
        }
    });
});
function delImage(){
//    $("#delbutton").click(function(){
       // $(this).parent().remove();
       $("#image_play").html("");
       $("#uploadify-queue").remove();
        $("#ad_img_path").val("");
        $("#uploadify").show();
        $("#upload_comment").show();
   // })
}
</script>

{include file="public/admin_foot.html"}